package cn.jdy.plugins.entity;

import cn.jdy.common.bo.BaseEntry;
import cn.jdy.framework.db.hibernate.Validator;
import cn.jdy.platform.entity.ConfValue;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;

/**
 * @author wuzhiliang
 * @title 商机信息实体类
 * @date 2014-03-12
 */
@Entity
public class Business extends BaseEntry implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid.hex")
	private String id;    //主键
	@Column(length = 50)
	private String summary;    //简介,标题
	@Validator
	@Column(length = 20)
	private String userName;    //姓名
	@Column(length = 20)
	private String province;// 代理地区 省
	@Column(length = 20)
	private String city;//代理地区 市
	@Column(length = 20)
	private String county;//代理地区  县级
	@Column(length = 50)
	private String address;//地址
	@Column(length = 20)
	private String telephone;  //联系电话
	@Column(length = 20)
	private String classId;    //分类
	@Column(length = 20)
	private String opeanDate;//	开业时间年月
	@DateTimeFormat(pattern="yyyy-MM-dd")
	@Column(columnDefinition = "date")
	private Date expiryDate;//失效日期
	private Double acreage;    //面积
	private Double inmoney;    //投入金额
	private Integer price;    //星数/价格
	private Integer stock;    //库存
	private Integer buyTimes;    //购买次数
	@Validator
	private Integer sort;   //排序
	private String jobprocess;//从业经历
	private String shopadress;//店面位置
	private String agentsform;//代理形式
	private String agentsGrade;//代理档次
	private String agentDetails;//代理详情(图文模式)
	@Validator
	private String status;   //状态0 待审核，1 审核通过， 2 下架、禁用， 3 删除
	@Validator
	private String isRecommend;   //状态0 不推荐，1 推荐
	private String remark;//备注
	@Validator
	@Column(columnDefinition = "datetime")
	private String updateTime;//修改时间
	@Validator
	private String creater;//上传者
	@Validator
	private String keyword;//关键字，用于SEO

	@ManyToOne(fetch = FetchType.EAGER)
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "creater", insertable = false, updatable = false)
	private Member member;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "classId", insertable = false, updatable = false)
	private ConfValue bClass;

	@ManyToMany(fetch = FetchType.EAGER)
	@Cascade(value = CascadeType.SAVE_UPDATE)
	@JoinTable(name = "business_pinlei",
			joinColumns = @JoinColumn(name = "businessId", referencedColumnName = "id"),
			inverseJoinColumns = @JoinColumn(name = "pinleiId"))
	private Set<ConfValue> bPinlei;

	@OneToMany(fetch = FetchType.EAGER)
	@JoinColumn(name = "businessId", referencedColumnName = "id", insertable = false, updatable = false)
	private Set<Discuss> discuss; //商机评论

	// ====(+)的属性不是字段 用于扩展 数据传输使用=====
	@Transient
	private String createrlevel;//(+)上传者 等级/积分 对应member的 score
	@Transient
	private Object collect;//是否已收藏

	public Object getCollect() {
		return collect;
	}

	public void setCollect(Object collect) {
		this.collect = collect;
	}

	public String getCreaterlevel() {
		return createrlevel;
	}

	public void setCreaterlevel(String createrlevel) {
		this.createrlevel = createrlevel;
	}

	public String getIsRecommend() {
		return isRecommend;
	}

	public void setIsRecommend(String isRecommend) {
		this.isRecommend = isRecommend;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCounty() {
		return county;
	}

	public void setCounty(String county) {
		this.county = county;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getClassId() {
		return classId;
	}

	public void setClassId(String classId) {
		this.classId = classId;
	}

	public Integer getBuyTimes() {
		return buyTimes;
	}

	public void setBuyTimes(Integer buyTimes) {
		this.buyTimes = buyTimes;
	}

	public String getOpeanDate() {
		return opeanDate;
	}

	public void setOpeanDate(String opeanDate) {
		this.opeanDate = opeanDate;
	}

	public Double getAcreage() {
		return acreage;
	}

	public void setAcreage(Double acreage) {
		this.acreage = acreage;
	}

	public Double getInmoney() {
		return inmoney;
	}

	public void setInmoney(Double inmoney) {
		this.inmoney = inmoney;
	}

	public Integer getPrice() {
		return price;
	}

	public void setPrice(Integer price) {
		this.price = price;
	}

	public Integer getStock() {
		return stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getJobprocess() {
		return jobprocess;
	}

	public void setJobprocess(String jobprocess) {
		this.jobprocess = jobprocess;
	}

	public String getShopadress() {
		return shopadress;
	}

	public void setShopadress(String shopadress) {
		this.shopadress = shopadress;
	}

	public String getAgentsform() {
		return agentsform;
	}

	public void setAgentsform(String agentsform) {
		this.agentsform = agentsform;
	}

	public String getAgentsGrade() {
		return agentsGrade;
	}

	public void setAgentsGrade(String agentsGrade) {
		this.agentsGrade = agentsGrade;
	}

	public String getAgentDetails() {
		return agentDetails;
	}

	public void setAgentDetails(String agentDetails) {
		this.agentDetails = agentDetails;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}

	public String getCreater() {
		return creater;
	}

	public void setCreater(String creater) {
		this.creater = creater;
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public ConfValue getbClass() {
		return bClass;
	}

	public void setbClass(ConfValue bClass) {
		this.bClass = bClass;
	}

	public Set<ConfValue> getbPinlei() {
		return bPinlei;
	}

	public void setbPinlei(Set<ConfValue> bPinlei) {
		this.bPinlei = bPinlei;
	}

	public Set<Discuss> getDiscuss() {
		return discuss;
	}

	public void setDiscuss(Set<Discuss> discuss) {
		this.discuss = discuss;
	}

	public String getKeyword() {
		return keyword;
	}

	public Date getExpiryDate() {
		return expiryDate;
	}

	public void setExpiryDate(Date expiryDate) {
		this.expiryDate = expiryDate;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
}
